package com.hc.server.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 工具类
 * @author xujh
 *
 */
public class Util {

	public static Date Time2Date(String time) throws ParseException{
		Date date = new SimpleDateFormat("yyyyMMddHHmmss").parse(time);
		return date;
	}
	
	public static Date Date2SQLDate(Date date) throws ParseException{
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Date sqlDate = format.parse(format.format(date));
		return sqlDate;
	}
	
	public static Date Date2SQLDate(String date) throws ParseException{
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Date sqlDate = format.parse(date);
		return sqlDate;
	}

	public static String Date2Calender(Date date) throws ParseException{
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		String calender = format.format(date);
		return calender;
	}

	public static String Date2Time(Date date) {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String time = format.format(date);
		return time;
	}
}
